<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:77:"D:\Code\matian\matian\application\admin\view\bootstrap\appointment\index.html";i:1492419162;}*/ ?>
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2>在线预约</h2>
        <ol class="breadcrumb">
            <li>
                <a href="#">首页</a>
            </li>

            <li class="active">
                <strong>在线预约</strong>
            </li>
        </ol>
    </div>

</div>

<div class="wrapper wrapper-content animated fadeInRight ecommerce">

    <div class="ibox-content m-b-sm border-bottom" id="form1">
        <div class="row">
            <div class="col-sm-3">
                <div class="form-group">
                    <label class="control-label" for="contact">联系人</label>
                    <input type="text" id="contact" name="contact" placeholder="联系人"
                           class="form-control">
                </div>
            </div>
            <div class="col-sm-3">
                <div class="form-group">
                    <label class="control-label" for="identity">身份证号码</label>
                    <input type="text" id="identity" name="identity" placeholder="身份证号码"
                           class="form-control">
                </div>
            </div>
            <div class="col-sm-3">
                <div class="form-group">
                    <label class="control-label" for="identity">审核状态</label>
                    <?php echo W('parts/op',['name'=>'status','key'=>'auth','value'=>'']); ?>
                </div>
            </div>
            <div class="col-sm-3">
                <div class="form-group">
                    <label class="control-label" for="telephone">手机号码</label>
                    <input type="text" id="telephone" name="telephone" placeholder="手机号码"
                           class="form-control">
                </div>
            </div>
            <div class="col-sm-3">
                <div class="form-group">
                    <label class="control-label">居住地址</label>
                    <?php echo W('parts/combo',['model'=>'area','name'=>'area_id','defaultValue'=>'']); ?>
                </div>
            </div>
            <div class="col-sm-3">
                <div class="form-group">
                    <label class="control-label" for="address">详细地址</label>
                    <input type="text" id="address" name="address" placeholder="详细地址"
                           class="form-control">
                </div>
            </div>
            <div class="col-sm-3">
                <div class="form-group">
                    <label class="control-label">预约的业务</label>
                    <?php echo W('parts/combo',['model'=>'business','name'=>'business_id','defaultValue'=>'']); ?>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">

            </div>
            <div class="col-sm-6 text-right">
                <button class="btn btn-default" data-op="reset">
                    <i class="fa fa-refresh"></i>
                    <span class="bold">重置</span>
                </button>
                &nbsp;
                &nbsp;
                <button class="btn btn-primary" data-op="search">
                    <i class="fa fa-search"></i>
                    <span class="bold">查询</span>
                </button>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-12">
            <div class="ibox">
                <div class="ibox-content">
                    <table class="footable table table-stripped toggle-arrow-tiny" id="footable">
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(document).ready(function () {
        var table = YFootTable.create('#footable', {
            baseUrl: "<?php echo U('Appointment/'); ?>",
            searchForm: '#form1',
            sort: 'status asc,id',
            order: 'desc',
            columns: [
                {name: 'contact', title: '联系人', sortable: true}
                , {name: 'identity', title: '身份证号码', sortable: true, breakpoints: 'xs sm md'}
                , {name: 'telephone', title: '手机号码', sortable: true, breakpoints: 'xs sm md'}
                , {name: 'area_name', title: '居住地址', sortable: true, breakpoints: 'xs sm md'}
                , {name: 'auth__status', title: '审核状态', sortable: true, breakpoints: 'xs sm md'}
                , {name: 'address', title: '详细地址', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'appoint_date', title: '预约日期', sortable: true, breakpoints: 'xs sm md'}
                , {name: 'appoint_time', title: '预约时间', sortable: true, breakpoints: 'xs sm md'}
                , {name: 'during__appoint_during', title: '预约时长', sortable: true, breakpoints: 'xs sm md'}
                , {name: 'business_name', title: '预约的业务', sortable: true, breakpoints: 'xs sm md'}
            ],
            actions: [{
                text: '通过',
                token:'accept',
                handler: function (row) {
                    YMessager.confirm({
                        title: "确定审核通过所选记录吗?",
                        text: "审核通过后,用户会收到微信推送"
                    }, function () {
                        $.post("<?php echo U('setAuth'); ?>", {
                            status: 1,
                            id:row.id
                        }, function (rt) {
                            if(rt.status == 1){
                                table.loadData();
                                YMessager.toast('操作成功');
                            }else{
                                YMessager.alert(rt.info);
                            }
                        }, 'json');
                    });
                }
            }, {
                text: '拒绝',
                token:'reject',
                handler: function (row) {
                    swal({
                                title: "审核拒绝",
                                text: "审核拒绝后,用户会收到微信推送",
                                type: "input",
                                showCancelButton: true,
                                closeOnConfirm: false,
                                confirmButtonText: "确定",
                                cancelButtonText: '取消',
//                                animation: "slide-from-top",
                                inputPlaceholder: "在这输入理由",
                                showLoaderOnConfirm: true
                            },
                            function (inputValue) {
                                if (inputValue === false) return false;
                                if (inputValue === "") {
                                    swal.showInputError("拒绝的理由不能为空");
                                    return false
                                }
                                $.post("<?php echo U('setAuth'); ?>", {
                                    reason: inputValue.trim(),
                                    status: 2,
                                    id:row.id
                                }, function (rt) {
                                    if(rt.status == 1){
                                        table.loadData();
                                        YMessager.toast('操作成功');
                                    }else{
                                        YMessager.alert(rt.info);
                                    }
                                }, 'json');

                            });
                }
            }, 'view', 'edit', 'remove']
        });
    });
</script>